use crate::handlers::course::*;

use actix_web::web;

pub fn course_routes(cfg: &mut web::ServiceConfig) {
  cfg.service(
    web::scope("/courses")
      // curl -X POST http://127.0.0.1:8080/courses/ -H "Content-Type: application/json" -d '{"teacher_id": 1, "name": "First course"}'
      .route("/", web::post().to(post_new_course))
      .route("/", web::get().to(get_all))
      // curl http://127.0.0.1:8080/courses/1
      .route("/{teacher_id}", web::get().to(get_courses_for_teacher))
      // curl http://127.0.0.1:8080/courses/1/2
      .route(
        "/{teacher_id}/{course_id}",
        web::get().to(get_course_detail),
      )
      // curl -X DELETE http://127.0.0.1:8080/courses/1/1
      .route("/{teacher_id}/{course_id}", web::delete().to(delete_course))
      // curl -X PUT http://127.0.0.1:8080/courses/1/2  -H "Content-Type: application/json" -d '{"name": "First Course", "description": "1 + 1 = 3", "language": "Math Course"}'
      .route(
        "/{teacher_id}/{course_id}",
        web::put().to(update_course_details),
      ),
  );
}
